//
//  VisitorView.swift
//  WeiBo
//
//  Created by Tony on 2017/12/27.
//  Copyright © 2017年 Tony. All rights reserved.
//

import UIKit

class VisitorView: UIView {
    class func visitorView() -> VisitorView {
        return Bundle.main.loadNibNamed("VisitorView", owner: nil
            , options: nil)?.first as! VisitorView
    }
    
    
    @IBOutlet weak var rotationView: UIImageView!
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var tipLabel: UILabel!
    
    // 如下两个属性用于事件监听
    // 有别于传统的监听方法，传统方法：代理，通知，block或闭包

    @IBOutlet weak var registerBtn: UIButton!
    @IBOutlet weak var loginBtn: UIButton!
    
    func setupVisitorViewInfo(iconName: String, tip: String) {
        iconView.image = UIImage.init(named: iconName)
        tipLabel.text = tip
        rotationView.isHidden = true
    }
    
    func addRotationAnim() {
        // 创建动画
        let rotationAnim = CABasicAnimation.init(keyPath: "transform.rotation.z")
        // 设置动画属性
        rotationAnim.fromValue = 0
        rotationAnim.toValue = M_PI * 2
        rotationAnim.repeatCount = MAXFLOAT
        rotationAnim.duration = 5
        // 保证切换界面后依然有动画效果
        rotationAnim.isRemovedOnCompletion = false
        
        // 图层添加动画
        rotationView.layer.add(rotationAnim, forKey: nil)
        
    }
    
}
